<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <title>科转</title>
    <link rel="stylesheet" href="assets/libs/layui/css/layui.css"/>
    <style>
  
        .login-header {
            color: rgba(0, 0, 0, .85) !important;
            padding: 5% 0;
            text-align: center;
        }
        .layui-text em, .layui-word-aux {
            color: #ef0909 !important;
            padding: 0 5px !important;
        }
        .layui-input-block {
             margin-left: 0;
            min-height: 46px;
        }
        @media screen and (min-width: 800px) {
			.layui-form-label{
				width: 86px !important;
			}	
            .smallbox{
                font-size: 4vh !important;
                margin: 15px !important;
            }
		}
		.content_box{
			max-width: 760px;
			padding: 0px;
		}
        .imgbanner{
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .imgbanner img{
            width: 100%;
        }
        .entrance{
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
        }
        .smallbox{
            width: 45%;
            height: auto;
            background-color: #8dc63f;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 2vh;
            color: #fff;
            margin: 10px;
			padding-top: 2%;
			padding-bottom: 2%;
        }
        .smallbox img{
            width: 30%;
        }
        .smallbox:nth-child(2){
            background-color: #3576FD;
        }
        .smallbox:nth-child(3){
            background-color: #39b54a;
        }
        .smallbox:nth-child(4){
            background-color: #1cbbb4;
        }
    </style>
</head>
<body>
<div class="body">
    <div class="layui-fluid content_box">
        <div class="imgbanner">
            <img src="./assets/images/sxdx.png" alt="">
        </div>
        <div class="entrance">
            <div class="smallbox" onclick="goaddapply()">
                <img src="./assets/images/icon_ck.png" alt="">
                <p>我要转让</p>
            </div>
            <div class="smallbox" onclick="bindHrefPage()">
                <img src="./assets/images/kc_see.png" alt="">
                <p>转让记录</p>
            </div>
            <div class="smallbox" onclick="bindHrefPage()">
                <img src="./assets/images/icon_pdjl.png" alt="">
                <p>专利许可</p>
            </div>
            <div class="smallbox" onclick="bindHrefPage()">
                <img src="./assets/images/icon_pd.png" alt="">
                <p>专利盘活</p>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="assets/js/config.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script src="https://wwcdn.weixin.qq.com/node/open/js/wecom-jssdk-1.3.1.js"></script>
<script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js" referrerpolicy="origin"></script>

<script>
    layui.config({
        base: 'assets/module/'
    }).use(['layer', 'form','upload'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var upload = layui.upload;
        var router = layui.router();


        let userMsg = localStorage.getItem("userMsg");
        if (userMsg==null || !userMsg){  //如果没有获取到用户信息， 进行授权获取
            var code = getUrlParam('code');
            var hreftemp = window.location.href;

            console.log(code,"============获取用户信息完成====================");
            if(code==null || !code ){ //如果没有code进行重定向
                if(hreftemp.indexOf('uhref=')>0){
                    return;
                }else{
                    //跳转获取code
                    $.post("https://desheng.hot68.cn/sxdx/api/public/index.php/app/Wxprogramehtml/getOAuthRedirectUrl", {'url':hreftemp}, function(res) {
                        window.location.href = res.obj;
                    }, "json");
                }
                return;
            }else{ //通过凑得获取登录信息
				$.post("https://desheng.hot68.cn/sxdx/api/public/index.php/app/Wxprogramehtml/getUserByCode", {'code':code}, function(res) {
				    localStorage.setItem("userMsg",JSON.stringify(res.obj));
					location.reload();
				}, "json");
				return;
			}
        }

		userMsg = localStorage.getItem("userMsg");
		//准备注册授权
		var userMsg2 = JSON.parse(userMsg)
		console.log(userMsg2,'----------------------------1111----------')
		//获取用户信息， 通过code
		$.post("https://desheng.hot68.cn/sxdx/api/public/index.php/app/Wxprogramehtml/getTwoTicket", 
		            {'corpid':userMsg2['CorpId'],'urlAdress':window.location.href}, function(res) {
			let config = res.obj.config;
			let agentConfig =  res.obj.agentConfig;
		
			console.log(res,'----------------------------2222----------')
			ww.register({
				corpId: config.corpid,
				agentId:config.agentid,
				jsApiList:["selectEnterpriseContact","selectExternalContact","openUserProfile","selectPrivilegedContact"],
				getConfigSignature() {
					  return ww.getSignature(config.ticket)
					},
				getAgentConfigSignature(){
					return ww.getSignature(agentConfig.ticket)
				},
				onAgentConfigFail(){
					console.log("签名失败");
				},
				onAgentConfigSuccess: function (res) {
					regSunccFun();
				},
				error: function (res) {
					//请求异常回调
					console.log(res)
					return false;
				}
			})
		}, "json");


		function regSunccFun(){
			ww.initOpenData({
			    success: function (res) {
			        console.log(WWOpenData, "初始化完成了哈哈哈哈")					
			        /*const openid = '123MuTouRen'
			        document.getElementById('userData').setAttribute('openid', openid);
			        WWOpenData.bind(document.querySelector('ww-open-data'));
						
			        console.log(WWOpenData, "初始化完成了哈哈哈哈")*/
			    },
			    error: function (res) {
			        //请求异常回调
			        console.log("======================2")
			        console.log(res)
			        return false;
			    }
			});
		}

        function viewPort() {
            const meta = document.querySelector('meta[name="viewport"]');
            const scale = window.screen.width / 375 < 1 ? 1 : window.screen.width / 375;
            meta.content = `width=device-width,initial-scale=${scale}`
        }
        viewPort()
        window.onresize = viewPort;
});


function goaddapply(params) {
    window.location.href = `addapplyknow.html`;
}
function bindHrefPage(params) {
    window.location.href = `turnrecord.html`;
}
</script>
</body>
</html>